var arr = [['a', 'b'], ["A", "B"], ["1", "2"]];
// 结果 Aa1，Aa2，Ab1，Ab2，Ba1，Ba2，Bb1，Bb2


function genAll(arr) {
    let result = []
    let temp = []
    let dep = 0;

    function dfs(temp, dep) {
        if (arr.length === dep) {
            result.push(temp.join(""))
            return; // 要return
        }
        for (let i = 0; i < arr[dep].length; i++) { // 要添加dep
            temp.push(arr[dep][i])
            dfs(temp, dep + 1)
            temp.pop()
        }
    }

    dfs(temp, dep)
    return result
}


console.log(genAll(arr))



// 数组全排列: https://leetcode-cn.com/problems/permutations/submissions/